<template>
  <view class="pages_login">
    <view class="login_input">
      <u-input
        placeholder="请输入登录账户"
        clearable
        :border="true"
        v-model="form.username"
      ></u-input>
    </view>
    <view class="login_input">
      <u-input
        placeholder="请输入登录密码"
        clearable
        :border="true"
        type="password"
        v-model="form.password"
      ></u-input>
    </view>
    <view class="login_input">
      <u-button @click="merchantLogin" type="error">登录</u-button>
    </view>
    <!-- <view class="login_input login_btn" @click="toApplyStore"> 申请店铺 </view> -->
  </view>
</template>

<script>
import { login } from "@/api/admin";

export default {
  data() {
    return {
      form: {
        username: "",
        password: "",
      },
    };
  },
  methods: {
    async merchantLogin() {
      let form = this.form;
      if (form.username === "" || form.password === "") {
        this.$utils.toast("请填写账户密码信息~");
      }
      const res = await login(form, true);
      if (res.code === 0 && res.data.Authorization) {
        uni.setStorageSync(
          "storeAdminToken",
          "Bearer " + res.data.Authorization
        );
        uni.reLaunch({
          url: "/admin/home/home",
        });
      }
    },
    toApplyStore() {
      this.$utils.toUrl("/salesman/salesman/applyShop");
    },
  },
};
</script>

<style lang="scss" scoped>
.pages_login {
  padding: 30rpx;
  .login_input {
    margin-bottom: 30rpx;
  }
  .login_btn {
    padding-top: 30rpx;
    text-align: center;
    color: #007bff;
  }
}
</style>
